#include "serial.h"
#include "FreeRTOS.h" // TODO: why needed for uart?


void Serial_Ini(void)
{
    /* Configure the UART and interrupts. */
    uint16 usBRG = (uint16)(((float)configPERIPHERAL_CLOCK_HZ / ((float)16*(float)115200)) - (float)0.5);
    OpenUART2( UART_EN, UART_RX_ENABLE | UART_TX_ENABLE | UART_INT_TX | UART_INT_RX_CHAR, usBRG);
    ConfigIntUART2((configKERNEL_INTERRUPT_PRIORITY + 1) | UART_INT_SUB_PR0 | UART_TX_INT_EN | UART_RX_INT_EN );

    // TODO: need a common ini flag
    Serial_Tx_Ini();
    Serial_Rx_Ini();
}
